<?php

class Profilestatusescontroller {

	public function __construct( $registry, $userID, $profileID, $profileChanged, $profile ){
		$this->registry = $registry;
		$profile_type = $profile->getProfileType();
		$this->listRecentStatuses($profile, $profileChanged);
	}

	/**
	 * List recent statuses on a users profile
	 * @param int $user the user whose profile we are viewing
	 * @return void
	 */
	private function listRecentStatuses( $userProfile, $profileChanged )
	{
		$user = $userProfile->getUserID();
		$profile = $userProfile->getProfileID();		
			
		// post status / public message box
		if( $this->registry->getObject('authenticate')->isLoggedIn() == true )
		{		
			if ($profileChanged == 2)
			{
				unset($_SESSION['sn_min_status_id']);
				
				$refresh = 0;
				if (isset($_POST['refresh']))
					$refresh = $_POST['refresh'];
					
				$this->registry->getObject('template')->buildFromTemplates('main/main.tpl.php', 'main/main_menu.tpl.php', 'main/main_content.tpl.php',
							'wall/wall.tpl.php', 'wall/wallmsgs.tpl.php', 'wall/wallfooter.tpl.php', 'main/footer.tpl.php');
				
				
				unset ($_POST['refresh']);
					
				require_once( FRAMEWORK_PATH . 'models/Wall.php');
				$wall = new Wall($this->registry);
				$wall->Updates( $userProfile);
			}
			else
			{
				unset($_SESSION['sn_min_status_id']);
				
				$refresh = 0;
				if (isset($_POST['refresh']))
					$refresh = $_POST['refresh'];
				
				// load the templates if a URL call
				if ($profileChanged == 1)
				{
					if (!$refresh)
						$this->registry->getObject('template')->buildFromTemplates('main/main.tpl.php', 'main/main_menu.tpl.php','main/main_content.tpl.php',
							'wall/wall.tpl.php', 'wall/wallmsgs.tpl.php', 'wall/wallfooter.tpl.php', 'main/footer.tpl.php');
					else
						$this->registry->getObject('template')->buildFromTemplates('main/main_content.tpl.php',
							'wall/wall.tpl.php', 'wall/wallmsgs.tpl.php', 'wall/wallfooter.tpl.php', 'main/footer.tpl.php');
				}
				else 
				{
					if (!$refresh)
						$this->registry->getObject('template')->buildFromTemplates('main/main.tpl.php', 'main/main_menu.tpl.php', 'main/main_content.tpl.php',
							'wall/wall.tpl.php', 'wall/wallmsgs.tpl.php', 'wall/wallfooter.tpl.php', 'main/footer.tpl.php');
				
					else
						$this->registry->getObject('template')->buildFromTemplates('wall/wall.tpl.php', 
							'wall/wallmsgs.tpl.php', 'wall/wallfooter.tpl.php', 'main/footer.tpl.php');
				}
					
				unset ($_POST['refresh']);
					
				require_once( FRAMEWORK_PATH . 'models/Wall.php');
				$wall = new Wall($this->registry);
				$wall->Updates($userProfile);
			}
		}
		else
		{
			$this->registry->getObject('template')->getPage()->addTag( 'status_update', '' );
		}

	}
	
	
	private function listfacebookStatses($userProfile, $profileChanged){
		
	}
}

?>
